package service

import (
	"context"
	"day5/user-sage/auth-service/basic/handler/model"
	"day5/user-sage/auth-service/basic/pkg"
	__2 "day5/user-sage/auth-service/basic/proto"
)

type Service struct {
	__2.UserServer
}

func (s Service) CreateUser(_ context.Context, in *__2.LoginUserReq) (*__2.LoginUserResp, error) {

	var user model.User
	user = model.User{
		Username: in.Username,
		Password: pkg.Md5str(in.Password),
	}
	err := model.Login(&user)
	if err != nil {
		return &__2.LoginUserResp{
			Code: 0,
			Msg:  "注册失败",
		}, nil
	}
	return &__2.LoginUserResp{
		Code: 200,
		Msg:  "注册成功",
	}, nil
}
